<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>
<%@page import="java.util.*"%>
<%@page import="org.ntu.csn.as.model.*"%>
<jsp:useBean id="n" class="org.ntu.csn.as.manager.WebManager" scope="session"/>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Homepage of Authoring System for PSLE Mathematics</title>
</head>

<body>
<p>
  <%@include file="tpl_header.jsp"%></p>
   <script type="text/javascript">  
 $(document).ready(function() {
	 $("#box-table-a tr").hover(
			  function () {
				  $(this).addClass('tablehighlight');
			  }, 
			  function () {
			    $(this).removeClass('tablehighlight');
			  }
			);
	 });
 
           </script>
  <center><img src="imgs/variables.png" width="400px" height="90px"></center>
  
<table width="100%" border="0" cellspacing="0" cellpadding="4">

 
  
</table>
<%
List<Obj> clist = (List<Obj>)request.getAttribute("objList");
String action = (String)request.getAttribute("action");
SysMessage errorMsg = (SysMessage)request.getAttribute("errorMsg");
%>
<div id="content" align="center">
				<h1>Topics</h1>
				<form name="topicListForm" method="post" action="QuestionDesignController">
				<table width="50%" id="box-table-a" border="1">
				<tr>
				
					<th>Name</th>
					<th>Type</th>
					<th>Manage</th>
					<th>Delete</th>
				</tr>
				<%for(Obj c:clist) {%>
				<tr>
				
					<td><font color="red"><b><%=c.getName() %></b></font></td>
					<td><b><%=n.getObjType(c.getType()).getName()%></b></td>
					<td><a href="ObjSelectController?id=<%=c.getId()%>"><img src="imgs/gifIcons/reply.gif" border ="0"/></a></td>
					<td><a href="ObjDeleteController?id=<%=c.getId()%>"><img src="imgs/gifIcons/action_delete.gif" border ="0"/></a></td>
				</tr>
				<% }%>
			
				
				</table>
				</form>
				
                <%if(("update").equals(action) ){%>
				<h1>Update A Variable</h1>
				<% 
				} else { 
				%>
				<h1>Add A Variable</h1>
				<%} %>
				
				<form name="input" action="ObjAddController" method="post">
				<table id="newspaper-a">
				<input type="hidden" name="action" value="<%=action%>"/>
				<%
				  Obj obj = (Obj)request.getAttribute("obj");
				%>
				<input type="hidden" name="id" value="<%=obj==null?null:obj.getId()%>"/>
					<tr>
						<th>ID</th>
						<td><input name="id" type="id" id="id" value="<%=obj==null?"No Need to Input":obj.getId()%>" readonly/></td>
					</tr>
					<tr>
						<th>Name</th>
						<td><input name="name" type="text" id="grade" value="<%=obj==null?"Please input name":obj.getName()%>"/></td>
					</tr>	
					<tr>
						<th>Type</th>
						<td><select name="type" title="Type of this variable.">
						<option value="1" <%if(obj!=null){if(obj.getType()==1){%>selected<%}} %>>Object</option>
						<option value="2" <%if(obj!=null){if(obj.getType()==2){%>selected<%}} %>>Person</option>
						</select></td>
					</tr>	 
					
						<tr>
					
						<font color="red"> <%=errorMsg==null?"":errorMsg.getMessage()%> </font>
					</tr>	
	
					<tr> <td>&nbsp;</td><td><input type="submit" value="  <%=("update").equals(action)?"update":"add"%>  "/></td></tr>
				</table>
				</form>
				



		</div>
		<p>&nbsp;</p>

<p>&nbsp;</p>

<table border="0" align="center">
<tr>
<td><a href="index.jsp"><img src="imgs/backToMain.png" width="400px" height="80px"/></a></td>
<td><a href="QuestionMan.jsp"><img src="imgs/design_question_templates.png" width="400px" height="80px"/></a></td>
</tr>
</table>

<p> 
  <%@include file="tpl_footer.jsp"%>
</p>
</body>
</html>
